package de.baumann.browser.activitys.duobao

import android.content.Context
import android.content.Intent
import de.baumann.browser.OdinGlideModule
import de.baumann.browser.R
import de.baumann.browser.adapter.WuLiuAdapter
import de.baumann.browser.api.net.vo.duobao.WuLiu
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.iview.duobao.IWuLiuView
import de.baumann.browser.present.duobao.IWuLiuPresenter
import de.baumann.browser.utils.StringUtil
import kotlinx.android.synthetic.main.activity_wu_liu.*
import kotlinx.android.synthetic.main.include_tool_bar_2.*

class WuLiuActivity : BaseOdinActivity<IWuLiuView, IWuLiuPresenter>(), IWuLiuView {

    companion object {
        fun startWuLiuActivity(context: Context, id: String,n:String) {
            context.startActivity(Intent(context, WuLiuActivity::class.java).apply {
                putExtra("id", id)
                putExtra("n",n)
            })
        }
    }

    private lateinit var wuLiuAdapter: WuLiuAdapter

    override fun getLayout(): Int {
        return R.layout.activity_wu_liu
    }


    override fun getTitleText(): String {
        return "物流详情"
    }

    override fun getBackIcon(): Int {
        return R.drawable.ic_back
    }

    override fun initView() {
        initToolbar(commToolBar, commTitle)
        fzdh.setOnClickListener {
            StringUtil.copy(mContext,wldhs)
            showShortToast("单号已复制")
        }
        jpmc.text = intent.getStringExtra("n")
        wuLiuAdapter = WuLiuAdapter()
        wuliuList.adapter = wuLiuAdapter
    }

    override fun initData() {
        presenter?.getWuLiu()
    }

    override fun createPresenter(): IWuLiuPresenter {
        return IWuLiuPresenter()
    }

    override fun createView(): IWuLiuView {
        return this
    }

    override val id: String
        get() = intent.getStringExtra("id")

    override fun setSHR(s: String) {
        wlshr.text = "收货人:${s}"
    }

    override fun setAddress(a: String) {
        shdz.text = "收货地址:${a}"
    }

    private var wldhs = ""
    override fun setDanHao(dh: String) {
        this.wldhs = dh
        wldh.text = "单号：${dh}"
    }

    override fun setJPTP(tp: String) {
        OdinGlideModule.load(mContext,tp,wlfm,R.drawable.shape_cover)
    }

    override fun setWuLiu(list: List<WuLiu>?) {
        if (list==null){
            return
        }
        wuLiuAdapter.setNewData(list)
    }

    override fun setWuLiuMC(mc: String) {
        wuliumc.text = mc
    }
}